package com.da.orderPojo.controller;


import com.da.orderPojo.Order;
import com.da.orderPojo.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单控制器
 *
 * @Author chen
 * @Date 2025/8/6 16:53
 */
@Slf4j
@RestController
public class OrderController {
    //注入订单服务
    @Autowired
    private OrderService orderService;

    /**
     * 创建订单
     * @param userId
     * @param productId
     * @return
     */
    @GetMapping("/createOrder")
    public Order createOrder(@RequestParam("userId") Long userId, @RequestParam("productId") Long productId){
        log.info("创建订单开始,用户id{},商品id{}", userId, productId);
        return orderService.createOrder(userId, productId);

    }

}
